home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc / Sample Code / CALib & You… / Documentation / CALib API⁄Source Reference 1 next >
Encoding:
Text File  |  1995-12-15  |  17.6 KB  |  535 lines  |  [TEXT/ttxt]

  1. CALib API/Source Reference - Part 1
  2. By The OpenDoc™ Engineering Team
  3. December 15, 1995
  4.  
  5.  
  6. © 1993-1995  Apple Computer, Inc. All Rights Reserved.
  7. Apple, the Apple logo, and Macintosh are registered trademarks of Apple Computer, Inc.
  8. Mac and OpenDoc are trademarks of Apple Computer, Inc.
  9. ----------------------------------------------------------------------------------------------------------------------------
  10.  
  11.  
  12. Introduction
  13.  
  14. The following is an overview of the API/Source for CALib.  It is a compendium of discussions, OpenDoc™ documentation, developer experience and our current understandings.
  15.  
  16. The CALib API is modeled after the QuickTime APIs.  The caller is required to check for it’s presence and avoid calling the API if it is not installed.
  17.  
  18.  
  19. CALib API
  20.  
  21. Arbitration    - CAArbitr.cpp
  22.  
  23. Description
  24.  
  25. This module contains routines used by the CA to deal with focus arbitration.  The root frame of the specified window is the focus frame.  If focus notification callbacks are registered, the  proxy part calls through appropriately.
  26.  
  27. CALib defines the following focus types: kCAPrimaryFocus and kCAModalFocus.
  28.  
  29. CALib calls ExportClipboard() before calling the FocusAcquired() callback. 
  30.  
  31.  
  32. API
  33.  
  34. pascal Boolean    CARequestStandardFocusSet( WindowPtr window )
  35. Acquire focus for the CA
  36. Exceptions signaled: 
  37.     none
  38.  
  39. pascal void    CARelinquishStandardFocusSet( WindowPtr window )
  40. Used to relinquish focus when embedded parts request acquisition of  focus
  41. Exceptions signaled:
  42.     kCAErrInvalidRequestor
  43.  
  44. pascal Boolean    CARequestModalFocus( WindowPtr window )
  45. Must be called prior to bringing up any CA dialogs that require modal behavior.
  46. Exceptions signaled:
  47.     none
  48.  
  49. pascal void    CARelinquishModalFocus( WindowPtr window )
  50. Must be called after closing any  CA dialogs that require modal behavior.
  51. Exceptions Handled:
  52.     kCAErrInvalidRequestor
  53.  
  54.  
  55.  
  56.  
  57. Clipboard    - CAClip.cpp
  58.  
  59. Description
  60.  
  61. CAGetClipboardDocument() acquires the clipboard focus for the caller and sets up the ODClipboard object to be used by the CA.  The cloneKind is used to determine whether or not to clear the ODClipboard object. cloneKind may be kCACloneCopy, kCACloneCut or kCAClonePaste.
  62.  
  63. CACloseDocument() is called by the CA when the data transfer operation is complete.
  64.  
  65. The current CA clipboard implementation requires the CA to call CASetDocumentKind()  to set the content value to the CA scrap type.
  66.  
  67.  
  68. Related Recipes
  69.  
  70. Copying native content + embedded frames to the clipboard.
  71. Copying a single embedded frame to the clipboard
  72. Pasting native content + embedded frames from the clipboard.
  73. Pasting a single embedded frame from the clipboard.
  74. Embedding the contents of the clipboard as a part (same as above?)
  75.  
  76.  
  77. API
  78.  
  79. pascal    CADocumentRef CAGetClipboardDocument(CADocumentRef reqDoc, CACloneKind cloneKind)
  80. Returns the reference to the OpenDoc Clipboard document.
  81. Exceptions signaled:
  82.     none
  83.  
  84.  
  85.  
  86.  
  87. Data Interchange    - CADataX.cpp
  88.  
  89. The CADataX API provides the CA with the mechanism to clone frames (and their parts) to/from data transfer objects.  The type of clone is determined from the cloneKind stored by the CADocument object representing the data transfer object. (E.g.. CAClipboardDocument, CADragDropDocument).
  90.  
  91. CACloneFrameRef() can handle the following clone contexts.
  92.  
  93.     Clone between a CADocument and a data transfer document.
  94.     Clone from an OpenDoc CADocument (OD container file) to a CADocument.
  95.  
  96. The isRootFrameRef parameter to CACloneFrameRef indicates that either a single frame clone to a data transfer document, or a clone of the root part of a OpenDoc document to the CA document.
  97.  
  98. A CACloneKey is a pointer to a CACloneInfo object, which is used internally by CALib to manage a clone transaction.
  99.  
  100. class CACloneInfo
  101. {
  102.  
  103.     public:
  104.     
  105.                     CACloneInfo(ODDraftKey draftKey);
  106.                     ~CACloneInfo();
  107.         void            AddFrameID (ODID frameID);
  108.         ODULong        GetFrameIDCount (void);
  109.         OrderedCollectionIterator*    CreateFrameIterator (void);
  110.         
  111.         Boolean        fCloneComplete;
  112.         ODDraftKey        fDraftKey;
  113.  
  114.     private:
  115.         
  116.         OrderedCollection*    fFrameIDList;
  117.     
  118. };
  119.  
  120.  
  121. API
  122.  
  123. pascal CAFrameRef CACloneFrameRef(    CAFrameRef    fromFrameRef,
  124.                     CAFrameRef    toFrameRef,
  125.                     CADocumentRef    fromDocument,
  126.                     CADocumentRef    toDocument,
  127.                     Boolean        isRootFrameRef,
  128.                     CACloneKey    cloneKey)
  129. Exceptions signaled:
  130.     kCAErrInvalidCloneKey
  131.     kCAErrInvalidFrame
  132.     kCAErrOutOfMemory
  133.  
  134. pascal CACloneKey CABeginClone(    CADocumentRef sourceDocument, 
  135.                     CADocumentRef destDocument )
  136. Calls BeginClone to begin a copy -transfer from one OD document to another
  137. Exceptions signaled:
  138.     kCAErrCloningInProgress
  139.  
  140.  
  141.     
  142.  
  143. pascal void    CAEndClone(    CADocumentRef sourceDocument, 
  144.                 CADocumentRef destDocument, 
  145.             CACloneKey clonekey )
  146. Calls EndClone to end a copy  transfer from the source document. 
  147. Exceptions signaled:
  148.     kCAErrInvalidCloneKey
  149.  
  150.  
  151. pascal void    CARemoveFrameRef(     CADocumentRef document, 
  152.                     CAFrameRef frame )
  153. Removes the frame (and any embedded frames) from the document. This is used when cutting or deleting a part embedded in the CA’s document.
  154. Exceptions signaled:
  155.     kCAErrInvalidFrame
  156.  
  157. pascal    void    CAGetRootFrameRef(    CADocumentRef    document,
  158.                     WindowPtr        window,
  159.                     CAFrameRef        rootFrameRef )
  160. Returns a CAFrameRef associated with the root frame of the specified document.
  161. Exceptions signaled:
  162.     kCAErrInvalidDocument
  163.  
  164.  
  165. Display    - CADisplay.cpp
  166.  
  167. In order to make the frame contents visible, a call must be made to CAMakeVisFrame() which creates an OpenDoc facet that can be displayed by the CA. The facet is returned to the CA as a CAVisFrame (internally an ODFacet*). All display activities will be performed using this reference. The CAAdjustVisFrame() call is used to manipulate the visibility attributes associated with the facet such as display clipping and positioning within the presentation.
  168.  
  169. Manipulation of visFrame positioning is performed by manipulating the frame’s external transform. This is an opaque data type to the CA implementor. In order to facilitate manipulation of the transform data, two utility functions have been provided: CAMoveTransformBy, and CAMoveTransformTo. Other calls that would implement other transform manipulations may be implemented as required.
  170.  
  171. The CARemoveVisFrame() call removes the indicated facet from the frame. This  serves to avoid redraw of parts not visible when scrolled off of the screen. This would be useful as a performance optimization only. 
  172.  
  173. Note that this API only supports a single VisFrame (OpenDoc facet) per frame, as there is no way to distinguish between multiple facets.
  174.  
  175. Offscreen canvases work mostly transparently. If a CA wants an embedded part to image offscreen, it should provide the GWorld/viewport (or appropriate data type) to the MakeVisFrame call. Also, the CA must provide a callback for Part::UpdateCanvas so that OpenDoc can post notification that the part canvas has been updated.
  176.  
  177. CAs which want to do advanced imaging tricks like tinting, transparency, interleaving, etc. must force drawing of embedded parts using a CAForceUpdate call.
  178.  
  179. The container application must draw the border and handles for the embedded parts when the border is selected (i.e. the embedded part is being resized or moved).
  180.  
  181. API
  182.  
  183. pascal CAVisFrame CAGetVisFrame( CADocumentRef document, 
  184.                 CAFrameRef frame )
  185. Gets the facet (visFrame) for the indicated frame.
  186. Exceptions signaled:
  187.     none
  188.  
  189. pascal CAVisFrame CAMakeVisFrame( CADocumentRef document,
  190.                 CAFrameRef frame,
  191.                 RgnHandle clipRgn,
  192.                 CATransform* xform,
  193.                 GrafPtr port )
  194. Creates a facet for the indicated frame.
  195. Exceptions signaled:
  196.     none
  197.                                     
  198. pascal    void    CARemoveVisFrame( CAVisFrame visFrame );
  199. Removes the facet from its frame.
  200. Exceptions signaled:
  201.     none
  202.  
  203. pascal void    CAAdjustVisFrame( CAVisFrame visFrame, 
  204.                 RgnHandle clipRgn, 
  205.                 CATransform* xform )
  206. Permits the CA to change the transform  and/or clipping  shape of the facet (CAVisFrame)
  207. Exceptions signaled:
  208.     none
  209.  
  210. pascal void CAGetVisFrameTransform(    CADocumentRef    document,
  211.                     CAFrameRef        frameRef,
  212.                     CATransform*    xform )
  213. Retrieves the facet’s external transform.
  214. Exceptions signaled:
  215.     none
  216.                                     
  217. pascal Boolean    CAGetSelected( CAVisFrame visFrame)
  218. Get the facet’s isSelected flag.
  219. Exceptions signaled:
  220.     none
  221.  
  222. pascal void    CASetSelected( CAVisFrame visFrame, 
  223.                 Boolean isSelected )
  224. Set the facet’s isSelected flag.
  225. Exceptions signaled:
  226.     none
  227.  
  228. pascal CAHighlight CAGetHighlight( CAVisFrame visFrame )
  229. Get the highlight state of the facet
  230. Exceptions signaled:
  231.     none
  232.  
  233. pascal void    CASetHighlight( CAVisFrame visFrame, 
  234.                 CAHighlight highlight )
  235. Set the highlight state of the facet and notify its part via part::HighlightChanged()
  236. Exceptions signaled:
  237.     none
  238.  
  239. pascal void    CAMoveTransformBy    (CATransform* transform, Point offset);
  240. Shifts the transform by the amount indicated in offset. Utility function.
  241. Exceptions signaled:
  242.     none
  243.  
  244. pascal void    CAMoveTransformTo    (CATransform* transform, Point origin);
  245. Shifts the transform to the new origin. Utility function.
  246. Exceptions signaled:
  247.     none
  248.  
  249.  
  250.  
  251. Drag and drop    - CADnd.cpp
  252.  
  253. This module provides a Drag&Drop interface to the CA, which interacts appropriately with the ODDragAndDrop object.  Internally, the CADnd implementation essentially duplicates much of the functionality implemented in DragDrp.cpp, with modifications to handle CALib specific issues.
  254.  
  255. CAStartDrag sets up the Macintosh Drag&Drop DragReference to include flavors written to the CADragDrop document by the CA and also other default flavors required by OpenDoc.
  256.  
  257. Note:     The routines CARemoveTrackingHandler() and CARemoveReceiveHandler() were removed
  258.     from the API, pre-DR3.
  259.  
  260. API
  261.  
  262. pascal CADocumentRef    CAGetDragDropDocument(CACloneKind cloneKind, ItemReference theItem)
  263. Acquires and initializes the CADragDropDocument object.
  264. Exceptions signaled:
  265.     none
  266.  
  267. pascal CADropResult CAStartDrag(    CADocumentRef    document,
  268.                     EventRecord*    event,
  269.                     RgnHandle        dragRgn)
  270.  
  271. Initiates a drag operation.  Calls TrackDrag()
  272.  
  273.  
  274. pascal OSErr     CAInstallTrackingHandler(     DragTrackingHandler    trackingHandler,
  275.                         WindowPtr        window,
  276.                         void             *handlerRefCon )
  277. Installs a TrackingHandler for OpenDoc
  278. Exceptions signaled:
  279.     kCAErrExistingHandler
  280.  
  281. pascal OSErr     CAInstallReceiveHandler(     DragTrackingHandler    trackingHandler,
  282.                         WindowPtr        window,
  283.                         void *handlerRefCon )
  284. Installs a Receive  Handler
  285. Exceptions signaled:
  286.     kCAErrExistingHandler
  287.  
  288. pascal OSErr     CARemoveTrackingHandler(     DragTrackingHandler    trackingHandler,
  289.                         WindowPtr        window)
  290. Removes the specified TrackingHandler .
  291. Exceptions signaled:
  292.     kCAErrExistingHandler
  293.  
  294. pascal OSErr     CARemoveReceiveHandler(     DragReceiveHandler    receiveHandler
  295.                         WindowPtr        window)
  296. Removes the specified ReceiveHandler .
  297. Exceptions signaled:
  298.     kCAErrExistingHandler
  299.  
  300. pascal void CASetDataSendProc(    CADocumentRef    document,
  301.                     DragSendDataUPP sendProc,
  302.                     void*            refCon)
  303. Installs a CA Data Send procedure
  304.  
  305.  
  306.  
  307. Document    - CADoc.cpp
  308.  
  309. Description
  310.  
  311. To a CA, a CADocumentRef represents  an OpenDoc data stream, which may be associated with a CA document,  the OpenDoc clipboard, the OpenDoc Drag&Drop, or an OpenDoc part document.  
  312.  
  313. CACreateDocument() is used by the CA to create new embedding units.  CAOpenDocument() may be used to open previously saved CA CADocument’s or OpenDoc part documents.
  314.  
  315. For each open document, CALib internally maintains a working ODFileContainer.  CASaveDocument() will either save the working file container, or copy a stream representation of the file container to the CA for later reconstitution.
  316.  
  317.  
  318. CASetDocumentKind() and CAGetDocumentKind() are used to access the current value stream of the documents kCAPropContents property.  CASetDocumentKind() sets the type of the first value in the kODPropContents property.  The CALib Stream API can then be used to read/write data to/from the value stream.
  319.  
  320.  
  321. API
  322.  
  323. pascal CADocumentRef    CACreateDocument(     FSSpecPtr    docSpec,
  324.                         Handle        docHandle)
  325. Creates an OpenDoc Document and returns a CADocumentRef. 
  326. Exceptions signaled:
  327.     none
  328.  
  329. pascal CADocumentRef    CAOpenDocument(    FSSpecPtr    docSpec,
  330.                         Handle        docHandle,
  331.                         CAOffset    offset, 
  332.                         CASize        length )
  333. Opens the OpenDoc document.  The length and offset allow the ODFileContainer stream to be obtained from
  334. the CA.
  335. Exceptions signaled:
  336.     kCAErrInvalidDocument
  337.     kCAErrCannotOpenDocument
  338.  
  339. pascal void     CASaveDocument(    CADocumentRef    document,
  340.                     FSSpecPtr    newFile,
  341.                     Handle        docHandle,
  342.                     CAOffset    offset, 
  343.                     CASize*        length,
  344.                      )
  345. Ensures that all embedded parts are properly externalized.  Offset & Length allow the ODFileContainer
  346. to be streamed to a CA file.
  347. Exceptions signaled:
  348.     kCAErrInvalidDocument
  349.     kCAErrCannotSaveDocument
  350.  
  351. pascal void     CACloseDocument(    CADocumentRef    document)
  352. Tears down and deallocates all parts and their data which were internalized from the given CADocumentRef. Closes the Document.
  353. Exceptions signaled:
  354.     kCAErrInvalidDocument
  355.  
  356. pascal Boolean    CAHasDocumentChanged( CADocumentRef document)
  357. Checks to see if any of the OpenDoc Document  Embedded Parts have changed.  Used for caching and to see if the Document needs to be rewritten.
  358. Exceptions signaled:
  359.     kCAErrInvalidDocument
  360.  
  361. pascal void    CASetDocumentKind(     CADocumentRef document, 
  362.                     CAISOStr    kind )
  363. Sets the current value stream of the kODContentsProperty of document.
  364. Exceptions signaled:
  365.     kCAErrInvalidDocument
  366.  
  367. pascal CAISOStr CAGetDocumentKind(     CADocumentRef document)
  368. Obtains the current value type of document.
  369. Exceptions signaled:
  370.     kCAErrInvalidDocument
  371.  
  372.  
  373. Multiple Document Kind Support
  374.  
  375. pascal Boolean        CAUseKind(    CADocumentRef document, CAISOStr kind, short index);
  376.  
  377. Sets the current value stream of the kODContentsProperty of document.
  378.  
  379.  
  380. pascal CAISOStr    CACurrentKind(    CADocumentRef document);
  381.  
  382. Gets the current value stream of the kODContentsProperty of document.
  383.  
  384.  
  385. pascal void        CAAddKind(    CADocumentRef document, CAISOStr kind);
  386.  
  387. Adds the value kind to the value stream of the kODContentsProperty of document.
  388.  
  389.  
  390. pascal void        CARemoveKind(    CADocumentRef document, CAISOStr kind);
  391.  
  392. Removes the value kind from the value stream of the kODContentsProperty of document.
  393.  
  394.  
  395. pascal CAISOStr    CAGetNthKind(    CADocumentRef document, short index);
  396.  
  397. Gets the Nth  value stream of the kODContentsProperty of document.
  398.  
  399.  
  400. pascal short        CAGetKindCount(CADocumentRef document);
  401.  
  402. Returns the number of values in the value stream of the kODContentsProperty of document.
  403.  
  404.  
  405. Error    - CAError.cpp
  406.  
  407. Description
  408.  
  409. This module contains CALib’s Error handling routines, CAError() and CASetErrorProc().
  410.  
  411. API
  412.  
  413. pascal OSErr     CAError( void )
  414. Returns the last set global error value.  It does not reset the value.
  415. Exceptions signaled:
  416.     none
  417.  
  418. pascal CAErrorProc CASetErrorProc( CAErrorProc proc )
  419. Sets the routine to be called when an error is reported by OpenDoc.
  420. Exceptions signaled:
  421.     kCAErrExistingErrorProc
  422.     kCAErrInvalidErrorProc
  423.  
  424.  
  425.  
  426. Inititialization    - CAInit.cpp
  427.  
  428. Description
  429.  
  430. This module contains initialization routines for CALib CAInit() & CAShutdown() are called by the CA.  CAInit() allocates and initializes a CASession object, CAShutdown() deletes the CASession object.
  431.  
  432. The CASession object maintains various data structures and state information relating to a single CALib session.
  433.  
  434.  
  435. API
  436.  
  437. pascal void    CAInit()
  438. Initializes a CALib Session.  Allocates and initializes an OpenDoc Session.
  439. Exceptions signaled:
  440.     kCAErrOutOfMemory
  441.  
  442. pascal void    CAShutdown()    
  443. This call must unregister any callbacks,  menu commands, etc...  that have been registered by the CA. This may require all CALib API’s to keep track of such modifications in a globally accessible list...
  444. Exceptions signaled:
  445.     none
  446.  
  447. pascal OSErr CALibCFMInit (InitBlockPtr initBlkPtr)
  448. Internal API only. Used to connect CALib with it’s resource fork at container (CFM) load time.
  449. Exceptions signaled:
  450.     ???
  451.  
  452.  
  453. Imaging    - CAImage.cpp
  454.  
  455.  
  456. API
  457.  
  458. pascal GrafPtr    CAGetCanvas(     CAVisFrame visFrame )
  459. Return the canvas this part’s facet should image on.
  460. Exceptions signaled:
  461.     none
  462.  
  463. pascal void    CADrawFrame(     CAVisFrame visFrame, 
  464.                 RgnHandle invalidRgn )
  465. Tell the facet’s part to draw itself in invalidRgn in this facet.
  466. Exceptions signaled:
  467.     none
  468.  
  469. pascal void    CAInstallCanvasNotification( CACanvasUpdatedProc proc )
  470. Allows CA to receive notification whenever a part’s representation has changed.
  471. Exceptions signaled:
  472.     kCAErrInvalidHandler
  473.  
  474. pascal void    CACanvasUpdated(    GrafPtr            port,
  475.                     CAGraphicsSystem    graphicSystem )
  476. Default proc for notification when the part’s canvas has changed.
  477. Exceptions signaled:
  478.     none
  479.  
  480.  
  481. Layout    - CALayout.cpp
  482.  
  483.  
  484. The Layout API allows the CA control and access of embedded frame’s display area and internal transform.   The frame shape and transform calls basically map directly to their ODFrame counterpart.
  485.  
  486. The internal transform of a frame represents the offset of the frame's content within the frame.
  487.  
  488. API
  489.  
  490. pascal    RgnHandle    CAGetFrameRgn(    CADocumentRef    document,
  491.                     CAFrameRef    frame )
  492. Returns a region that is the current  frame shape (frameShape set by the CA).
  493. Exceptions signaled:
  494.     none
  495.  
  496. pascal    void        CASetFrameRgn(    CADocumentRef    document,
  497.                     CAFrameRef    frame,
  498.                     RgnHandle    frameRgn )
  499. Sets/changes the frame shape
  500. Exceptions signaled:
  501.     none
  502.  
  503. pascal    RgnHandle    CAGetUsedRgn(    CADocumentRef    document,
  504.                     CAFrameRef    frame )
  505. Returns a region that is the current shape used by the frame (usedShape)
  506. Exceptions signaled:
  507.     none
  508.  
  509. pascal    void        CAGetFrameTransform(    CADocumentRef    document,
  510.                         CAFrameRef    frame,
  511.                         CATransform*    transform )
  512. Returns the internal transform for the frame.
  513. Exceptions signaled:
  514.     kCAErrInvalidFrameRef
  515.  
  516. pascal    void        CASetFrameTransform(    CADocumentRef    document,
  517.                         CAFrameRef    frame,
  518.                         CATransform*    transform )
  519. Replaces the contents of the internal transform for the referenced frame.
  520. Exceptions signaled:
  521.     none
  522.  
  523. pascal    Boolean        CAGetFrozen(        CADocumentRef    document,
  524.                         CAFrameRef    frame )
  525. Returns whether the indicated frame is frozen or not.
  526. Exceptions signaled:
  527.     kCAErrInvalidFrameRef
  528.  
  529. pascal    void        CASetFrozen(    CADocumentRef        document,
  530.                     CAFrameRef        frame,
  531.                     Boolean            isFrozen )
  532. Set whether the indicated frame is frozen or not.
  533. Exceptions signaled:
  534.     none
  535.